package com.android.boncen.commonFrame.fragment;

import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.Toast;

import com.android.boncen.commonFrame.R;

/**
 * 功能描述:血糖蛋白
 *
 * @date 2017/2/9
 */

public class AddXTDBialog extends AlertDialog {

    private EditText etXTDB;

    public AddXTDBialog(Context context, SaveCallback callback) {
        super(context, R.style.CustomDialogStyle);
        this.callback = callback;
    }

    public interface SaveCallback {
        void save(float gy);
    }

    SaveCallback callback;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.popupwindow_xtdm);
        getWindow().clearFlags(
                WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        etXTDB = (EditText) findViewById(R.id.etXTDB);
        findViewById(R.id.popup_bt_save).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                save(etXTDB.getText().toString());
            }
        });

    }

    private void save(String gy) {
        if (TextUtils.isEmpty(gy)) {
            Toast.makeText(getContext(), "不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        dismiss();
        callback.save(Float.valueOf(gy));

    }
}
